$(document).ajaxError(function(event, XMLHttpRequest, options) {
	var status = XMLHttpRequest.status;
	if (status == 403|| status==302) {
		var top=getTopWindow();
		top.location.href = 'login';
	}
});

$.ajaxSetup({
	cache : false,
	traditional : true,
	complete: function(XMLHttpRequest,ts){
		//console.log(XMLHttpRequest);
		var ctx1=XMLHttpRequest.responseText+"";
		if(ctx1.indexOf('static/js/md5.min.js') != -1){
			var top=getTopWindow();
			top.location.href = "login";
			return;
		}
	}
});

$.fn.serializeObject = function()
{
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};

function getTopWindow(){ 
    var p = window; 
    while(p != p.parent){ 
        p = p.parent; 
    } 
    return p; 
}

